/*!
\copyright  Copyright (c) 2019 - 2023 Qualcomm Technologies International, Ltd.\n
            All Rights Reserved.\n
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file       headset_pmalloc_pools.c
\brief      Definition of the pmalloc pools used by the headset application.

The pools defined here will be merged at run time with the base definitions
from OS - see 'pmalloc_config_P1.h'.
*/

#include <pmalloc.h>

_Pragma ("unitsuppress Unused")

_Pragma ("datasection apppool")

#ifdef USE_SYNERGY

#ifdef INCLUDE_LE_AUDIO_UNICAST

/* Additional the pools memory for LE Audio support:
   Additional blocks: 102
   Additional bytes:  3784
*/
#define APP_POOL_BLOCK_SIZE_4_ADDON_COUNT       20
#define APP_POOL_BLOCK_SIZE_8_ADDON_COUNT        3
#define APP_POOL_BLOCK_SIZE_12_ADDON_COUNT       7
#define APP_POOL_BLOCK_SIZE_16_ADDON_COUNT       4
#define APP_POOL_BLOCK_SIZE_20_ADDON_COUNT      19
#define APP_POOL_BLOCK_SIZE_24_ADDON_COUNT       4
#define APP_POOL_BLOCK_SIZE_28_ADDON_COUNT      12
#define APP_POOL_BLOCK_SIZE_32_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_36_ADDON_COUNT       1
#define APP_POOL_BLOCK_SIZE_44_ADDON_COUNT       2
#define APP_POOL_BLOCK_SIZE_56_ADDON_COUNT       3
#define APP_POOL_BLOCK_SIZE_64_ADDON_COUNT       4
#define APP_POOL_BLOCK_SIZE_80_ADDON_COUNT      16
#define APP_POOL_BLOCK_SIZE_100_ADDON_COUNT      2
#define APP_POOL_BLOCK_SIZE_128_ADDON_COUNT      3
#define APP_POOL_BLOCK_SIZE_160_ADDON_COUNT      2
#define APP_POOL_BLOCK_SIZE_180_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_220_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_512_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_692_ADDON_COUNT      0
#ifdef INCLUDE_GAMING_HEADSET_ADDON
#define APP_POOL_BLOCK_SIZE_1520_ADDON_COUNT     0
#define APP_POOL_BLOCK_SIZE_3000_ADDON_COUNT     0
#endif /* INCLUDE_GAMING_HEADSET_ADDON */
#define APP_POOL_BLOCK_SIZE_1400_ADDON_COUNT     0

#else /* INCLUDE_LE_AUDIO_UNICAST */

#define APP_POOL_BLOCK_SIZE_4_ADDON_COUNT        0
#define APP_POOL_BLOCK_SIZE_8_ADDON_COUNT        0
#define APP_POOL_BLOCK_SIZE_12_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_16_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_20_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_24_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_28_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_32_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_36_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_44_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_56_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_64_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_80_ADDON_COUNT       0
#define APP_POOL_BLOCK_SIZE_100_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_128_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_160_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_180_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_220_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_512_ADDON_COUNT      0
#define APP_POOL_BLOCK_SIZE_692_ADDON_COUNT      0
#ifdef INCLUDE_GAMING_HEADSET_ADDON
#define APP_POOL_BLOCK_SIZE_1520_ADDON_COUNT     0
#define APP_POOL_BLOCK_SIZE_3000_ADDON_COUNT     0
#endif /* INCLUDE_GAMING_HEADSET_ADDON */
#define APP_POOL_BLOCK_SIZE_1400_ADDON_COUNT     0

#endif /* INCLUDE_LE_AUDIO_UNICAST */

/* Additional pools required when TDL is extended to 12 devices */
#define APP_POOL_BLOCK_SIZE_8_EXTENDED_TDL      10
#define APP_POOL_BLOCK_SIZE_16_EXTENDED_TDL     5
#define APP_POOL_BLOCK_SIZE_20_EXTENDED_TDL     5
#define APP_POOL_BLOCK_SIZE_24_EXTENDED_TDL     5
#define APP_POOL_BLOCK_SIZE_36_EXTENDED_TDL     5

#ifdef INCLUDE_ACCESSORY_TRACKING
#define APP_POOL_BLOCK_SIZE_128_ACCESSORY_TRACKING  50
#define APP_POOL_BLOCK_SIZE_1400_ACCESSORY_TRACKING 2
#else
#define APP_POOL_BLOCK_SIZE_128_ACCESSORY_TRACKING  0
#define APP_POOL_BLOCK_SIZE_1400_ACCESSORY_TRACKING 0
#endif

#define APP_POOL_BLOCK_SIZE_4_BASE_COUNT        15
#define APP_POOL_BLOCK_SIZE_8_BASE_COUNT        25 + APP_POOL_BLOCK_SIZE_8_EXTENDED_TDL
#define APP_POOL_BLOCK_SIZE_12_BASE_COUNT       32
#define APP_POOL_BLOCK_SIZE_16_BASE_COUNT       58 + APP_POOL_BLOCK_SIZE_16_EXTENDED_TDL
#define APP_POOL_BLOCK_SIZE_20_BASE_COUNT       42 + APP_POOL_BLOCK_SIZE_20_EXTENDED_TDL
#define APP_POOL_BLOCK_SIZE_24_BASE_COUNT       20 + APP_POOL_BLOCK_SIZE_24_EXTENDED_TDL
#define APP_POOL_BLOCK_SIZE_28_BASE_COUNT       79
#define APP_POOL_BLOCK_SIZE_32_BASE_COUNT       21
#define APP_POOL_BLOCK_SIZE_36_BASE_COUNT       19 + APP_POOL_BLOCK_SIZE_36_EXTENDED_TDL
#define APP_POOL_BLOCK_SIZE_44_BASE_COUNT       24
#define APP_POOL_BLOCK_SIZE_56_BASE_COUNT       14
#define APP_POOL_BLOCK_SIZE_64_BASE_COUNT       10
#define APP_POOL_BLOCK_SIZE_80_BASE_COUNT       16
#define APP_POOL_BLOCK_SIZE_100_BASE_COUNT       0
/* One of 128 bytes blocks is added for DeviceDbSerialiser_MakeBackup() */
#define APP_POOL_BLOCK_SIZE_128_BASE_COUNT      19 + APP_POOL_BLOCK_SIZE_128_ACCESSORY_TRACKING
#define APP_POOL_BLOCK_SIZE_160_BASE_COUNT       8
#define APP_POOL_BLOCK_SIZE_180_BASE_COUNT       2
#define APP_POOL_BLOCK_SIZE_220_BASE_COUNT       2
/* One of this blocks has been added for AMA hairpin functionality. */
#define APP_POOL_BLOCK_SIZE_512_BASE_COUNT       1
#define APP_POOL_BLOCK_SIZE_692_BASE_COUNT       3
#ifdef INCLUDE_GAMING_HEADSET_ADDON
#define APP_POOL_BLOCK_SIZE_1520_BASE_COUNT      3
#define APP_POOL_BLOCK_SIZE_3000_BASE_COUNT      3
#endif /* INCLUDE_GAMING_HEADSET_ADDON */
#define APP_POOL_BLOCK_SIZE_1400_BASE_COUNT      0 + APP_POOL_BLOCK_SIZE_1400_ACCESSORY_TRACKING

#define APP_POOL_BLOCK_ENTRY(size) \
    {size, APP_POOL_BLOCK_SIZE_##size##_BASE_COUNT + APP_POOL_BLOCK_SIZE_##size##_ADDON_COUNT}


static const pmalloc_pool_config app_pools[] =
{
    APP_POOL_BLOCK_ENTRY(4),
    APP_POOL_BLOCK_ENTRY(8),
    APP_POOL_BLOCK_ENTRY(12),
    APP_POOL_BLOCK_ENTRY(16),
    APP_POOL_BLOCK_ENTRY(20),
    APP_POOL_BLOCK_ENTRY(24),
    APP_POOL_BLOCK_ENTRY(28),
    APP_POOL_BLOCK_ENTRY(32),
    APP_POOL_BLOCK_ENTRY(36),
    APP_POOL_BLOCK_ENTRY(44),
    APP_POOL_BLOCK_ENTRY(56),
    APP_POOL_BLOCK_ENTRY(64),
    APP_POOL_BLOCK_ENTRY(80),
#ifdef INCLUDE_LE_AUDIO_UNICAST
    APP_POOL_BLOCK_ENTRY(100),
#endif
    APP_POOL_BLOCK_ENTRY(128),
    APP_POOL_BLOCK_ENTRY(160),
    APP_POOL_BLOCK_ENTRY(180),
    APP_POOL_BLOCK_ENTRY(220),
    APP_POOL_BLOCK_ENTRY(512),
    APP_POOL_BLOCK_ENTRY(692),
#ifdef INCLUDE_GAMING_HEADSET_ADDON
    APP_POOL_BLOCK_ENTRY(1520),
    APP_POOL_BLOCK_ENTRY(3000),
#endif /* INCLUDE_GAMING_HEADSET_ADDON */
#ifdef INCLUDE_ACCESSORY_TRACKING
    APP_POOL_BLOCK_ENTRY(1400)
#endif
    /* Including the pools in pmalloc_config_P1.h:
       Total pools:  19
       Total blocks: 410
       Total bytes:  17244 + (19 * 24) = 17700
    */
};

#else /* USE_SYNERGY */

static const pmalloc_pool_config app_pools[] =
{
    {   4, 15 },
    {   8, 25 },
    {  12, 32 },
    {  16, 13 },
    {  20, 31 },
    {  24, 20 },
    {  28, 55 },
    {  32, 21 },
    {  36, 19 },
    {  40, 10 },
    {  56,  9 },
    {  64,  7 },
    {  80,  9 },
    { 120, 14 },
    { 160,  8 },
    { 180,  2 },
    { 220,  2 },
    { 288,  1 }, /* for theGatt = gattState */
    { 512,  1 },
    { 692,  3 }

    /* Including the pools in pmalloc_config_P1.h:
       Total pools:  20
       Total blocks: 325
       Total bytes:  14076 + (20 * 24) = 14556
    */
};

#endif /* USE_SYNERGY */

